import contextlib
import urllib

class Requestor:
    def __init__(self, base):
        self._urlbase = base
        
    def DoPost(self, args):
        request = self._urlbase
        params = urllib.urlencode(dict(zip([arg for arg in args], [args[arg] for arg in args])))
        
        with contextlib.closing(urllib.urlopen(request, params)) as url:
            return url.read()
    
    def DoRequest(self, args):
        request = self._urlbase
        t = []
        for arg in args:
            string = arg + "=" + args[arg]
            t.append(string)
        request += "&".join(t)
        
        with contextlib.closing(urllib.urlopen(request)) as url:
            return url.read()
    